package com.mccken.designpattern.proxy.jdkProxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @program: mccken-collect
 * @description:
 * @author: mccken
 * @create: 2022-10-27 10:42
 **/
public class McckenServiceDynamicProxyHandler implements InvocationHandler {
	private ITarget1 target1;
	public McckenServiceDynamicProxyHandler(ITarget1 target1) {
		this.target1 = target1;
	}
	
	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		System.out.println("invoke before "+ target1.getClass());
		
		Object invoke = method.invoke(target1, args);
		
		System.out.println("invoke after");
		return invoke;
	}
}
